const express = require('express')
      router = express.Router()
      
     router.get('/login/:username/:password',(req,res) =>{
				var pass = req.params.password
				var name = req.params.username
				User.find({username:name},function(err,data){
          
					if(err){
						send(res,'fail','很抱歉，系统错误')
					}else{
							if(data.length > 0){
									 if(data[0].username == name){
										  if(data[0].password == pass){
										  	res.cookie('username',name)
										  	res.cookie('ownerId',data[0]._id)
										  	if(data[0].header){
									  			res.cookie('header',data[0].header)
										  	}else{
										  		res.cookie('header','images/user.png')
										  	}
										  	send(res,'success','登录成功')
										  }else{
										  	send(res,'fail','您输入的密码错误')
										  }
									}else{
										send(res,'fail','您输入的用户名不存在')
									}
										
								}else{
								send(res,'fail','您输入的用户名不存在')
							}
							
					}
				})
     })
      
      
      
      
      
      
      
      
      
      
      
module.exports = router
